package org.smile.homework01.kevin.WithDrawMoney;

import java.util.ArrayList;
import java.util.List;


public class CBRC implements Subject{        //定义被观察者， 本次定义为取款金额？
    private List<Observer> list;
    private double amount;
    private String message;

    public CBRC() {
        list = new ArrayList<Observer>();
    }

    @Override
    public void registerObserver(Observer o) {
        list.add(o);
    }

    @Override
    public void removeObserver(Observer o) {
        if (!list.isEmpty()) {
            list.remove(o);
        }
    }



    @Override
    public void notifyObserver() {
        for (Observer o : list) {
            o.record(amount);
        }
    }
    public void setInformation(double s){
        this.amount = s;
        System.out.println("本次取款" +  s + "元" + "需要银监会理事备案");
        notifyObserver();
    }
}
